home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: news.eng.convex.com!arco!usenet
- From: Brian Leach <lasbfl@aai.arco.com>
- Subject: Re: new with multidimensional arrays
- X-Nntp-Posting-Host: 136.226.116.1
- Content-Type: text/plain; charset=us-ascii
- Message-ID: <3172BAEA.5555@aai.arco.com>
- Sender: usenet@news.arco.com
- Content-Transfer-Encoding: 7bit
- Organization: ARCO Alaska Inc.
- References: <3169B9C3.2A10@MIT.EDU> <316EC85C.1A21@aai.arco.com>
- Mime-Version: 1.0
- Date: Mon, 15 Apr 1996 21:08:58 GMT
- X-Mailer: Mozilla 2.0 (X11; I; HP-UX A.09.05 9000/755)
-
- Brian Leach wrote:
- >
- > Darrel K Robertson wrote:
- > >
- > > Hi, I wonder if anyone can help me. I want to use "new" to create a
- > > multidimensional array, but don't know how. So far I have:
- > > complex *grid;
- > > scanf("%d %d", &nc, &nr);
- > > grid = new complex[nc][nr];
- > >
- > > Unfortunately this won't work. Any info would be much appreciated.
- > > Darrel.
- >
- > All but the left-most dimension of multiple dimensional arrays must be
- > known at compile time. This is because C and C++ internally generate
- > arrays of arrays, for proper indexing, the length has to be known when
- > the program compiles. You get around this by using the STL vector
- > classes.
- >
- > What you want to do is illegal.
- >
- > -Brian :-)
- > lasbfl@aai.arco.com
- Once again, I have made an error, all dimensions must be known
- at compile time. However, when passing the array to a function,
- the left-most dimension need not be known.
-
- -Brian :-(
-